package com.light.sys.controller;

import com.light.common.base.PageResult;
import com.light.common.base.ResponseResult;
import com.light.common.base.BaseController;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.light.sys.domain.SysMenuDO;
import com.light.sys.service.SysMenuService;
import com.light.sys.query.SysMenuQuery;

import java.util.List;


/**
 * 
 * @Description: 父菜单ID，一级菜单为0
 * @author yhr
 * @Version V1.0
 * @date 
 */

@RestController
@RequestMapping("/sys/sysMenu")
@Api(tags  =  "菜单管理",  description  =  "")
public class SysMenuController extends BaseController<SysMenuDO, SysMenuService>{
	@Autowired
	private SysMenuService sysMenuService;
	
    @ApiOperation(value="获取列表信息")
    @GetMapping("")
	public ResponseResult<PageResult<SysMenuDO>> data(SysMenuQuery sysMenuQuery){
		//查询列表数据
        PageResult pageResult=new PageResult(sysMenuService.data(sysMenuQuery)
                ,sysMenuService.count(sysMenuQuery),sysMenuQuery);
        return ResponseResult.success(pageResult);
	}

    @ApiOperation(value = "获取子节点列表")
    @GetMapping("/childerens/{id}")
    public ResponseResult<List<SysMenuDO>> childerens(@PathVariable("id") Long id) {
        List<SysMenuDO> menus = sysMenuService.selectChildrens(id);
        return ResponseResult.success(menus);
    }

}
